<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>cptts2.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="CPTTS2.1"></a><a href="cptts2.f.html#CPTTS2.1">CPTTS2</a>( IUPLO, N, NRHS, D, E, B, LDB )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      INTEGER            IUPLO, LDB, N, NRHS
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      REAL               D( * )
      COMPLEX            B( LDB, * ), E( * )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="CPTTS2.18"></a><a href="cptts2.f.html#CPTTS2.1">CPTTS2</a> solves a tridiagonal system of the form
</span><span class="comment">*</span><span class="comment">     A * X = B
</span><span class="comment">*</span><span class="comment">  using the factorization A = U'*D*U or A = L*D*L' computed by <a name="CPTTRF.20"></a><a href="cpttrf.f.html#CPTTRF.1">CPTTRF</a>.
</span><span class="comment">*</span><span class="comment">  D is a diagonal matrix specified in the vector D, U (or L) is a unit
</span><span class="comment">*</span><span class="comment">  bidiagonal matrix whose superdiagonal (subdiagonal) is specified in
</span><span class="comment">*</span><span class="comment">  the vector E, and X and B are N by NRHS matrices.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  IUPLO   (input) INTEGER
</span><span class="comment">*</span><span class="comment">          Specifies the form of the factorization and whether the
</span><span class="comment">*</span><span class="comment">          vector E is the superdiagonal of the upper bidiagonal factor
</span><span class="comment">*</span><span class="comment">          U or the subdiagonal of the lower bidiagonal factor L.
</span><span class="comment">*</span><span class="comment">          = 1:  A = U'*D*U, E is the superdiagonal of U
</span><span class="comment">*</span><span class="comment">          = 0:  A = L*D*L', E is the subdiagonal of L
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The order of the tridiagonal matrix A.  N &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  NRHS    (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The number of right hand sides, i.e., the number of columns
</span><span class="comment">*</span><span class="comment">          of the matrix B.  NRHS &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  D       (input) REAL array, dimension (N)
</span><span class="comment">*</span><span class="comment">          The n diagonal elements of the diagonal matrix D from the
</span><span class="comment">*</span><span class="comment">          factorization A = U'*D*U or A = L*D*L'.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  E       (input) COMPLEX array, dimension (N-1)
</span><span class="comment">*</span><span class="comment">          If IUPLO = 1, the (n-1) superdiagonal elements of the unit
</span><span class="comment">*</span><span class="comment">          bidiagonal factor U from the factorization A = U'*D*U.
</span><span class="comment">*</span><span class="comment">          If IUPLO = 0, the (n-1) subdiagonal elements of the unit
</span><span class="comment">*</span><span class="comment">          bidiagonal factor L from the factorization A = L*D*L'.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  B       (input/output) REAL array, dimension (LDB,NRHS)
</span><span class="comment">*</span><span class="comment">          On entry, the right hand side vectors B for the system of
</span><span class="comment">*</span><span class="comment">          linear equations.
</span><span class="comment">*</span><span class="comment">          On exit, the solution vectors, X.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDB     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array B.  LDB &gt;= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      INTEGER            I, J
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           CSSCAL
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          CONJG
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Quick return if possible
</span><span class="comment">*</span><span class="comment">
</span>      IF( N.LE.1 ) THEN
         IF( N.EQ.1 )
     $      CALL CSSCAL( NRHS, 1. / D( 1 ), B, LDB )
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( IUPLO.EQ.1 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Solve A * X = B using the factorization A = U'*D*U,
</span><span class="comment">*</span><span class="comment">        overwriting each right hand side vector with its solution.
</span><span class="comment">*</span><span class="comment">
</span>         IF( NRHS.LE.2 ) THEN
            J = 1
    5       CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Solve U' * x = b.
</span><span class="comment">*</span><span class="comment">
</span>            DO 10 I = 2, N
               B( I, J ) = B( I, J ) - B( I-1, J )*CONJG( E( I-1 ) )
   10       CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Solve D * U * x = b.
</span><span class="comment">*</span><span class="comment">
</span>            DO 20 I = 1, N
               B( I, J ) = B( I, J ) / D( I )
   20       CONTINUE
            DO 30 I = N - 1, 1, -1
               B( I, J ) = B( I, J ) - B( I+1, J )*E( I )
   30       CONTINUE
            IF( J.LT.NRHS ) THEN
               J = J + 1
               GO TO 5
            END IF
         ELSE
            DO 60 J = 1, NRHS
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Solve U' * x = b.
</span><span class="comment">*</span><span class="comment">
</span>               DO 40 I = 2, N
                  B( I, J ) = B( I, J ) - B( I-1, J )*CONJG( E( I-1 ) )
   40          CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Solve D * U * x = b.
</span><span class="comment">*</span><span class="comment">
</span>               B( N, J ) = B( N, J ) / D( N )
               DO 50 I = N - 1, 1, -1
                  B( I, J ) = B( I, J ) / D( I ) - B( I+1, J )*E( I )
   50          CONTINUE
   60       CONTINUE
         END IF
      ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Solve A * X = B using the factorization A = L*D*L',
</span><span class="comment">*</span><span class="comment">        overwriting each right hand side vector with its solution.
</span><span class="comment">*</span><span class="comment">
</span>         IF( NRHS.LE.2 ) THEN
            J = 1
   65       CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Solve L * x = b.
</span><span class="comment">*</span><span class="comment">
</span>            DO 70 I = 2, N
               B( I, J ) = B( I, J ) - B( I-1, J )*E( I-1 )
   70       CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Solve D * L' * x = b.
</span><span class="comment">*</span><span class="comment">
</span>            DO 80 I = 1, N
               B( I, J ) = B( I, J ) / D( I )
   80       CONTINUE
            DO 90 I = N - 1, 1, -1
               B( I, J ) = B( I, J ) - B( I+1, J )*CONJG( E( I ) )
   90       CONTINUE
            IF( J.LT.NRHS ) THEN
               J = J + 1
               GO TO 65
            END IF
         ELSE
            DO 120 J = 1, NRHS
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Solve L * x = b.
</span><span class="comment">*</span><span class="comment">
</span>               DO 100 I = 2, N
                  B( I, J ) = B( I, J ) - B( I-1, J )*E( I-1 )
  100          CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Solve D * L' * x = b.
</span><span class="comment">*</span><span class="comment">
</span>               B( N, J ) = B( N, J ) / D( N )
               DO 110 I = N - 1, 1, -1
                  B( I, J ) = B( I, J ) / D( I ) -
     $                        B( I+1, J )*CONJG( E( I ) )
  110          CONTINUE
  120       CONTINUE
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span>      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="CPTTS2.174"></a><a href="cptts2.f.html#CPTTS2.1">CPTTS2</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
